package com.ylbh.modules.member.controller;

import com.ylbh.common.pojo.member.vo.AreaListVO;
import com.ylbh.common.pojo.member.vo.AreaVo;
import com.ylbh.common.utils.*;
import com.ylbh.modules.member.service.AreaService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 *
 * 地区数据
 * @author mgh
 * @date 2019-04-17 10:30:39
 */
@RestController
@RequestMapping("member/area")
public class AreaController {
    @Autowired
    private AreaService areaService;

    @RequestMapping("queryProvinceList")
    @ApiOperation("返回省的名字及id")
    public CommonResult<List<AreaVo>> queryProvinceList() {
        List<AreaVo> provinceList = areaService.queryProvinceList();
        return Ref.ok(provinceList);
    }

    @RequestMapping("querySubordinateList")
    @ApiOperation("返回下级的名字及id")
    public CommonResult<List<AreaVo>> querySubordinateList(@RequestBody Long id) {
        List<AreaVo> provinceList = areaService.querySubordinateList(id);
        return Ref.ok(provinceList);
    }

    @ApiOperation("根据地区id获取信息")
    @RequestMapping("getAddressDetailsById/{id}")
    public CommonResult getAddressDetailsById(@PathVariable Integer id) {
        List<AreaVo> list = areaService.getAddressDetailsById(id);
        return Ref.ok(list);
    }
}
